package smedi.ismedi.web.bff.controller.securityman;


import com.smedi.ismedi.securityman.api.dto.request.*;
import com.smedi.ismedi.securityman.api.dto.response.AllowanceOfficerResponse;
import com.smedi.ismedi.securityman.api.dto.response.AllowanceResponse;
import com.smedi.ismedi.securityman.api.dto.response.FileResponse;
import com.smedi.ismedi.securityman.api.dto.response.PersonResponse;
import com.smedi.ismedi.securityman.api.feign.RemoteAllowanceFeignApi;
import com.smedi.ismedi.web.starter.common.PaginationData;
import com.smedi.ismedi.web.starter.common.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;


/**
* 津贴发放审批
* @author yangzhenzhou
* @date 2022/9/14
*/

@Slf4j
@Api(value = "津贴发放审批接口", tags = {"津贴发放审批接口"})
@RequestMapping(value = "/webbff/v1/allowance")
@RestController
@AllArgsConstructor
public class AllowanceFeignController {

    private final RemoteAllowanceFeignApi remoteAllowanceFeignApi;

    /**
     * 津贴发放申请
     *
     * @param addAllowanceRequest 津贴发放申请申请请求
     * @return ResponseData<AllowanceResponse>
     */
    @ApiOperation(value = "津贴发放申请", nickname = "津贴发放申请")
    @PostMapping(value = "/applyAllowance")
    ResponseData<AllowanceResponse> applyAllowance(@Validated @RequestBody AddAllowanceRequest addAllowanceRequest){
        return remoteAllowanceFeignApi.applyAllowance(addAllowanceRequest);
    }


    /**
     * 津贴发放修改
     *
     * @param updateAllowanceRequest 津贴发放修改请求
     * @return ResponseData<AllowanceResponse>
     */
    @ApiOperation(value = "津贴发放修改", nickname = "津贴发放修改")
    @PostMapping(value = "/updateAllowance")
    ResponseData<AllowanceResponse> updateAllowance(@Validated @RequestBody UpdateAllowanceRequest updateAllowanceRequest){
        return remoteAllowanceFeignApi.updateAllowance(updateAllowanceRequest);
    }


    /**
     * 津贴发放项目干事详情查询
     *
     * @param queryOfficerListRequset 津贴发放项目干事详情查询
     * @return ResponseData<List<AllowanceResponse>>
     */
    @ApiOperation(value = "津贴发放项目干事详情查询", nickname = "津贴发放项目干事详情查询")
    @PostMapping(value = "/queryAllowanceOfficerList")
    ResponseData<List<AllowanceOfficerResponse>> queryAllowanceOfficerList(@Validated @RequestBody QueryOfficerListRequset queryOfficerListRequset){
        return remoteAllowanceFeignApi.queryAllowanceOfficerList(queryOfficerListRequset);
    }


    /**
     * 津贴发放分页查询
     *
     * @param queryAllowancePageRequest 津贴发放分页查询请求
     * @return ResponseData<PaginationData<AllowanceResponse>>
     */
    @ApiOperation(value = "津贴发放分页查询", nickname = "津贴发放分页查询")
    @PostMapping(value = "/queryAllowancePage")
    ResponseData<PaginationData<AllowanceResponse>> queryAllowancePage(@Validated @RequestBody QueryAllowancePageRequest queryAllowancePageRequest){
        return remoteAllowanceFeignApi.queryAllowancePage(queryAllowancePageRequest);
    }

    /**
     * 津贴发放单个数据查询
     *
     * @param queryAllowanceByOneRequest 申请津贴单个数据查询request
     * @return ResponseData<AllowanceResponse>
     */
    @ApiOperation(value = "津贴发放单个数据查询", nickname = "津贴发放单个数据查询")
    @PostMapping(value = "/queryAllowanceByOne")
    ResponseData<AllowanceResponse> queryAllowanceByOne(@Validated @RequestBody QueryAllowanceByOneRequest queryAllowanceByOneRequest){
        return remoteAllowanceFeignApi.queryAllowanceByOne(queryAllowanceByOneRequest);
    }


    /**
     * 导出列表
     *
     * @param exportAllowanceRequest 导出津贴发放审批列表请求
     * @return ResponseEntity<byte [ ]>
     */
    @ApiOperation(httpMethod = "POST", value = "导出列表")
    @PostMapping(value = "/exportAllowance")
    ResponseEntity<byte[]> exportAllowance(@Validated @RequestBody ExportAllowanceRequest exportAllowanceRequest) throws IOException {
        return remoteAllowanceFeignApi.exportAllowance(exportAllowanceRequest);
    }

    /**
     * 津贴发放项目经理审批
     *
     * @param allowanceReviewPmRequest 津贴发放项目经理审批请求
     * @return ResponseData<AllowanceResponse>
     */
    @ApiOperation(value = "津贴发放项目经理审批", nickname = "津贴发放项目经理审批")
    @PostMapping(value = "/reviewPm")
    ResponseData<AllowanceResponse> reviewPm(@Validated @RequestBody AllowanceReviewPmRequest allowanceReviewPmRequest){
        return  remoteAllowanceFeignApi.reviewPm(allowanceReviewPmRequest);
    }

    /**
     *
     * @param allowanceReviewOrganizationRequest 津贴发放主体院EPC分管领导审批参数
     * @return ResponseData<AllowanceResponse>
     */
    @ApiOperation(value = "津贴发放主体院EPC分管领导审批", nickname = "津贴发放主体院EPC分管领导审批")
    @PostMapping(value = "reviewOrganization")
    ResponseData<AllowanceResponse> reviewOrganization(@Validated @RequestBody AllowanceReviewOrganizationRequest allowanceReviewOrganizationRequest){
        return  remoteAllowanceFeignApi.reviewOrganization(allowanceReviewOrganizationRequest);
    }

    /**
     * 工程部工程师审核
     *
     * @param allowanceReviewEngineerRequest 津贴发放工程部工程师审批请求
     * @return ResponseData<AllowanceResponse>
     */
    @ApiOperation(value = "津贴发放工程部工程师审批", nickname = "津贴发放工程部工程师审批")
    @PostMapping(value = "/reviewEngineer")
    ResponseData<AllowanceResponse> reviewEngineer(@Validated @RequestBody AllowanceReviewEngineerRequest allowanceReviewEngineerRequest){
        return  remoteAllowanceFeignApi.reviewEngineer(allowanceReviewEngineerRequest);
    }


    /**
     *工程部分管领导审核
     * @param allowanceReviewEngineerLeaderRequest 津贴发放工程部分管领导审批参数
     * @return ResponseData<AllowanceResponse>
     */
    @ApiOperation(value = "津贴发放工程部分管领导审批", nickname = "津贴发放工程部分管领导审批")
    @PostMapping(value = "reviewEngineerLeader")
    ResponseData<AllowanceResponse> reviewEngineerLeader(@Validated @RequestBody AllowanceReviewEngineerLeaderRequest allowanceReviewEngineerLeaderRequest) throws IOException {
        return  remoteAllowanceFeignApi.reviewEngineerLeader(allowanceReviewEngineerLeaderRequest);
    }

    @ApiOperation(value = "津贴发放新增-项目协议查询", nickname = "津贴发放新增-项目协议查询")
    @PostMapping(value = "/queryProjectAgreement")
    ResponseData<List<FileResponse>> queryProjectAgreement(@Validated @RequestParam(value = "projectId", required = true) @ApiParam(value = "项目id") Long projectId ){
        return remoteAllowanceFeignApi.queryProjectAgreement(projectId);
    }

    @ApiOperation(value = "津贴发放撤销", nickname = "津贴发放撤销")
    @PostMapping(value = "cancelAllowance")
    ResponseData<AllowanceResponse> cancelAllowance(@Validated @RequestBody CancelAllowanceRequest cancelAllowanceRequest){
        return remoteAllowanceFeignApi.cancelAllowance(cancelAllowanceRequest);
    }

    @ApiOperation(value = "项目下的【施工项目经理】职务查询", nickname = "项目下的【施工项目经理】职务查询")
    @PostMapping(value = "queryConstructionProjectManager")
    ResponseData<List<PersonResponse>> queryConstructionProjectManager(@Validated @RequestBody QueryConstructionProjectManagerRequest queryConstructionProjectManagerRequest){
        return remoteAllowanceFeignApi.queryConstructionProjectManager(queryConstructionProjectManagerRequest);
    }

}
